
*first set cd
*cd
*next use "baylor_relig_W3"

********************************************************************************
********************************************************************************
					* descriptions of religious identity:       *
					*   "how well do the following terms        *
					*    describe your religious identity?..."  *
********************************************************************************
********************************************************************************

label define well 1 "not at all" 2 "not very well" 3 "somewhat well" 4 "very well" 

*Bible believing
gen biblebelieving = Q12A
label value biblebelieving well

*Born again
gen bornagain = Q12B
label value bornagain well

*Charismatic
gen charismatic = Q12C
label value charismatic well

*New Age
gen newage = Q12D
label value newage well

*Evangelical
gen evangelical = Q12E
label value evangelical well

*Fundamentalist
gen fundamentalist = Q12F 
label value fundamentalist well

*Mainline
gen mainline = Q12G 
label value mainline well

*Pentacostal
gen pentecostal = Q12H 
label value pentecostal well

*Seeker
gen seeker = Q12I 
label value seeker well

*Spiritual
gen spiritual = Q12J
label value spiritual well

*Theologically conservative
gen theoconserv = Q12K
label value theoconserv well

*Theologically liberal
gen theoliberal = Q12L 
label value theoliberal well

*Traditional
gen traditional = Q12M
label value traditional well

********************************************************************************
*dummy vers
********************************************************************************
gen biblebelievingD = biblebelieving
recode biblebelievingD 1/2=1 3/4=2
gen bornagainD 		= bornagain
recode bornagainD 1/2=1 3/4=2
gen charismaticD   	= charismatic
recode charismaticD 1/2=1 3/4=2
gen newageD			= newage
recode newageD 1/2=1 3/4=2
gen evangelicalD  	= evangelical
recode evangelicalD 1/2=1 3/4=2
gen fundamentalistD	= fundamentalist
recode fundamentalistD 1/2=1 3/4=2
gen mainlineD 		= mainline
recode mainlineD 1/2=1 3/4=2
gen pentecostalD 	= pentecostal
recode pentecostalD 1/2=1 3/4=2
gen seekerD			= seeker
recode seekerD 1/2=1 3/4=2
gen spiritualD 		= spiritual
recode spiritualD 1/2=1 3/4=2
gen theoconservD 	= theoconserv
recode theoconservD 1/2=1 3/4=2
gen theoliberalD 	= theoliberal
recode theoliberalD 1/2=1 3/4=2
gen traditionalD	= traditional
recode traditionalD 1/2=1 3/4=2

********************************************************************************
********************************************************************************
							* Religious behaviors *
********************************************************************************
********************************************************************************

*church attendance
gen attend = Q4 
label define attend 0 "never" 1 "<1x/yr" 2 "1-2x/yr" 3 "severalx/yr" 4 "1x/mo"	5 "2-3x/mo" 6 "~weekly" 7 "weekly" 8 "mult x/weekly"
label value attend attend

********************************************************************************
********************************************************************************

*reading scriptures
gen reading = Q10
label define reading 0 "never" 1 "<1x/yr" 2 "1-2x/yr" 3 "severalx/yr" 4 "1x/mo"	5 "2-3x/mo" 6 "~weekly" 7 "weekly" 8 "mult x/weekly"
label value reading reading 

********************************************************************************
********************************************************************************

*praying
gen praying = Q11
label define praying 0 "never" 1 "certain occasions" 2 " <1x/week" 3 "few x/week" 4 "1x/day" 5 "mult x/day"
label value praying praying 

********************************************************************************
********************************************************************************
*performative aspects of religion
factor praying attend reading, pcf
predict performance
*rescaling into deciles in order to gain a little more sensibility of scores:
xtile performance10 = performance, n(10)
*rescaling to range from 0 to 1
gen performance01=(performance10-1)/9

********************************************************************************
********************************************************************************
							  * Religious beliefs *
********************************************************************************
********************************************************************************

*"religious"...how religious are you?
gen religious = Q3
recode religious 8=0
label define religious 0 "I don't know" 1 "Not at all" 2 "Not too" 3 "Somewhat" 4 "Very"
label value religious religious
 
********************************************************************************
********************************************************************************

*Do you agree or disagre with...
gen allreligtrue = Q15A
gen worshipsamegod = Q15B
gen earthlivingbeing = Q15C

	*add in label
	label define agreedisagree 1 "strongly disagree" 2 "disagree" 3 "agree" 4 "strongly agree"
	label value allreligtrue agreedisagree
	label value worshipsamegod agreedisagree
	label value earthlivingbeing agreedisagree

*universalism scale = Q15A & Q15B (pearson's: 0.58; alpha: 0.73)
egen universalism = rmean(Q15A Q15B)
gen universalism01 = (universalism-1)/3


********************************************************************************
********************************************************************************

*How likely is it that life after death....
gen unionwgod = Q16A
gen reunionwfam = Q16B
gen reincarnation = Q16C
gen eternalreward = Q16D 

	*reverse-code items so that pro-religious answer = higher values
	recode unionwgod 3=4 2=3 1=2 7=1 
	recode reunionwfam 3=4 2=3 1=2 7=1 
	recode reincarnation 3=4 2=3 1=2 7=1 
	recode eternalreward 3=4 2=3 1=2 7=1 
	
	*add in new labels
	label define likely 4 "very likely" 3 "somewhat likely" 2 "not at all likely" 1 "do not believe in life after death"
	label value unionwgod likely
	label value reunionwfam likely 
	label value reincarnation likely
	label value eternalreward likely
	
********************************************************************************
********************************************************************************
	
*Which statement comes closest to view on Bible?
gen bibleword = Q17

	*reverse-code items so that pro-religious answer = higher values
	recode bibleword 1=5 2=4 3=3 4=2 8=1
	
	*add in new labels
	label define bibleword 1 "don't know" 2 "bible = ancient book of legends" 3 "bible contains human errors" 4 "bible perfectly true, but needs interpreting" 5 "bible literally true"
	label value bibleword bibleword
	
********************************************************************************
********************************************************************************	

*Which statement comes closest to personal beliefs about god?
gen beliefingod = Q18

	*reverse-code items so that pro-religious answer = higher values
	recode beliefingod 1=7 2=6 3=5 4=4 5=3 6=2 7=1
	
	*add in new labels
	label define belief 1 "no opinion" 2 "atheist" 3 "don't know, couldn't know" 4 "believe in cosmic power" 5 "sometimes believe in god" 6 "believe in god w doubt" 7 "no doubt god" 
	label value beliefingod belief
	
********************************************************************************
********************************************************************************

*What do you think God is like?
gen concernedwworld = Q19A
gen angeredbymysin = Q19B
gen involvedinworld = Q19C
gen concernedwme = Q19D
gen involvedinmylife = Q19E
gen angeredbyhumansin = Q19F

	*add in labels (disagree strongly, disagree, agree, agree strongly)
	label value concernedwworld agreedisagree
	label value angeredbymysin agreedisagree
	label value involvedinworld agreedisagree
	label value concernedwme agreedisagree
	label value involvedinmylife agreedisagree
	label value angeredbyhumansin agreedisagree
	
********************************************************************************
********************************************************************************

*words that decribe God: 
gen absolute = Q20A
gen critical = Q20B
gen fatherly = Q20C
gen punishing = Q20D
gen just = Q20E
gen wrathful = Q20F
gen forgiving = Q20G
gen severe = Q20H 

	*add in labels (not very well, not well, well, very well)
	label value absolute well
	label value critical well
	label value fatherly well
	label value punishing well
	label value just well
	label value wrathful well
	label value forgiving well
	label value severe well  
	
********************************************************************************
********************************************************************************

*please indicate your agreement w the following: 
gen warmrelationship = Q21A
gen supportsme = Q21B
gen responsive = Q21C
gen impersonal = Q21D
gen nointerestproblems = Q21E
gen nointerestaffairs = Q21F
gen sometimesresponsive = Q21G
gen inconsistent = Q21H
gen feelloved = Q21I
gen godlovesall = Q21J
gen godloveeternal = Q21K
gen godneverfails = Q21L
gen hotandcold  = Q21M

	*add in labels (disagree strongly, disagree, agree, agree strongly)
	label value warmrelationship agreedisagree
	label value supportsme agreedisagree
	label value responsive agreedisagree
	label value impersonal agreedisagree
	label value nointerestproblems agreedisagree
	label value nointerestaffairs agreedisagree
	label value sometimesresponsive agreedisagree
	label value inconsistent agreedisagree
	label value feelloved agreedisagree
	label value godlovesall	 agreedisagree
	label value godloveeternal agreedisagree
	label value godneverfails agreedisagree
	label value hotandcold agreedisagree
	
********************************************************************************
********************************************************************************

*do the following exist?
gen devil = Q23A
gen heaven = Q23B
gen hell = Q23C
gen purgatory = Q23D
gen armageddon = Q23E
gen angels = Q23F
gen demons = Q23G

	*add in labels
	label define extent 1 "absolutely not" 2 "probably not" 3 "probably" 4 "absolutely" 
	label value devil extent
	label value heaven extent
	label value hell extent
	label value purgatory extent
	label value armageddon extent
	label value angels extent
	label value demons  extent
	
********************************************************************************
*denominational affiliation
********************************************************************************

gen denomination = .
replace denomination = 1 if Q1==12
replace denomination = 1 if Q1==13
replace denomination = 1 if Q1==14
replace denomination = 1 if Q1==17
replace denomination = 1 if Q1==18
replace denomination = 1 if Q1==20
replace denomination = 1 if Q1==21
replace denomination = 1 if Q1==22
replace denomination = 1 if Q1==23
replace denomination = 1 if Q1==24
replace denomination = 1 if Q1==25
replace denomination = 1 if Q1==27
replace denomination = 1 if Q1==31
replace denomination = 1 if Q1==33
replace denomination = 1 if Q1==36
replace denomination = 1 if Q1==37
replace denomination = 1 if Q1==43
replace denomination = 1 if Q1==44
replace denomination = 1 if Q1==45
replace denomination = 1 if Q1==7
replace denomination = 1 if Q1==10
replace denomination = 1 if Q1==32
replace denomination = 1 if Q1==39
replace denomination = 2 if Q1==16
replace denomination = 3 if Q1==29
replace denomination = 4 if Q1==1
replace denomination = 4 if Q1==6
replace denomination = 4 if Q1==11
replace denomination = 4 if Q1==19
replace denomination = 4 if Q1==28
replace denomination = 4 if Q1==38
replace denomination = 4 if Q1==41
replace denomination = 4 if Q1==9998
replace denomination = 4 if Q1==34
replace denomination = 4 if Q1==15
replace denomination = 4 if Q1==26
replace denomination = 4 if Q1==30
replace denomination = 5 if Q1==46

*distinguishing evangelicals
gen evangel_marker = .
gen white = (Q63A==1)
gen black = (Q63B==1)

replace evangel_marker = 1 if evangelical==3
replace evangel_marker = 1 if evangelical==4
replace evangel_marker = 1 if bornagain==3
replace evangel_marker = 1 if bornagain==4
replace denomination = 6 if evangel_marker==1 & denomination==1
replace denomination = 7 if denomination==1 & black==1

*labeling denominations
label define denomin 1 "protestant" 2 "catholic" 3 "jewish" 4 "other" 5 "none" 6 " evangel" 7 "black prot"
label value denomination denomin

*dummy vars for denom, excluded category = "other"

gen evangel = (denomination==6)
gen blackprot = (denomination==7)
gen none = (denomination==5)
gen jewish = (denomination==3)
gen catholic = (denomination==2)
gen protestant = (denomination==1)

********************************************************************************
************************** DIVINE ATTITUDES LCA ********************************
********************************************************************************

********************************************************************************
*to run LCA in stata via gsem, vars need to be coded 0,1; for LCA plug-in,
*  vars need to be coded 1,2. 
********************************************************************************

********************************************************************************
*begin with coding vars 0,1; here agree/disagree and well/not well formats are 
*  condensed so that higher values convey general agreement (pos) and lower 
*  values convey disagreement (neg).
********************************************************************************

*qualities 
gen absoluteD = absolute
recode absoluteD 1/2=0 3/4=1
gen criticalD = critical
recode criticalD 1/2=0 3/4=1
gen fatherlyD = fatherly
recode fatherlyD 1/2=0 3/4=1
gen punishingD = punishing
recode punishingD 1/2=0 3/4=1
gen justD = just
recode justD 1/2=0 3/4=1
gen wrathfulD = wrathful
recode wrathfulD 1/2=0 3/4=1
gen forgivingD = forgiving
recode forgivingD 1/2=0 3/4=1
gen severeD = severe
recode severeD 1/2=0 3/4=1

*god's agency (active)
gen concernedwworldD = concernedwworld
recode concernedwworldD 1/2=0 3/4=1
gen angeredbymysinD = angeredbymysin
recode angeredbymysinD 1/2=0 3/4=1
gen involvedinworldD = involvedinworld
recode involvedinworldD 1/2=0 3/4=1
gen concernedwmeD = concernedwme
recode concernedwmeD 1/2=0 3/4=1
gen involvedinmylifeD = involvedinmylife
recode involvedinmylifeD 1/2=0 3/4=1
gen angeredbyhumansinD = angeredbyhumansin
recode angeredbyhumansinD 1/2=0 3/4=1
	
*responsive
gen responsiveD = responsive
recode responsiveD 1/2=0 3/4=1
gen impersonalD = impersonal
recode impersonalD 1/2=0 3/4=1
gen inconsistentD = inconsistent
recode inconsistentD 1/2=0 3/4=1

*love
gen godlovesallD = godlovesall
recode godlovesallD 1/2=0 3/4=1
gen godloveeternalD = godloveeternal
recode godloveeternalD 1/2=0 3/4=1
gen godneverfailsD = godneverfails
recode godneverfailsD 1/2=0 3/4=1

*FOR GSEM, 11 items for analysis of divine: absoluteD criticalD fatherlyD punishingD justD wrathfulD forgivingD severeD angeredbymysinD involvedinworldD godneverfailsD

********************************************************************************
*in order to run the LCA plug in, vars need to be coded 1,2
********************************************************************************
gen  	absoluteD_lca 	 	 	 =  	absoluteD 			+	1
gen  	criticalD_lca  	 		 =  	criticalD 			+	1
gen  	fatherlyD_lca  	  		 =  	fatherlyD 			+	1
gen  	punishingD_lca  	 	 =  	punishingD 			+	1
gen  	justD_lca  	  			 =  	justD 				+	1
gen  	wrathfulD_lca  	 		 =  	wrathfulD 			+	1
gen  	forgivingD_lca  	 	 =  	forgivingD 			+	1
gen 	severeD_lca  	 		 =  	severeD 			+	1
gen 	concernedwworldD_lca   	 =  	concernedwworldD 	+	1
gen 	involvedinworldD_lca   	 =  	involvedinworldD 	+	1
gen  	angeredbyhumansinD_lca   =  	angeredbyhumansinD 	+	1
gen  	responsiveD_lca  	 	 =  	responsiveD 		+	1
gen  	impersonalD_lca 	  	 =  	impersonalD			+	1
gen 	inconsistentD_lca  	 	 =  	inconsistentD 		+	1
gen 	godlovesallD_lca  	 	 =  	godlovesallD 		+	1
gen  	godloveeternalD_lca  	 =  	godloveeternalD 	+	1
gen 	godneverfailsD_lca 	 	 =  	godneverfailsD		+	1


*FOR LCA PLUG-IN, 11 items for analysis of divine: absoluteD_lca criticalD_lca fatherlyD_lca punishingD_lca justD_lca wrathfulD_lca forgivingD_lca severeD_lca angereD_lcabymysinD_lca involveD_lcainworlD_lcaD_lca goD_lcaneverfailsD_lca

********************************************************************************
********************************  ORTHODOXY  ***********************************
********************************************************************************

********************************************************************************
*begin with coding vars 0,1; here agree/disagree and well/not well formats are 
*  condensed so that higher values convey general agreement (pos) and lower 
*  values convey disagreement (neg). as of 2/23/2017, i have NOT run an LCA for
*  these items; instead, they are wrapped into a different index of "literalism"
*  that is explained below
********************************************************************************

*universalism
gen allreligtrueD = allreligtrue
recode allreligtrueD 1/2=1 3/4=0
gen worshipsamegodD = worshipsamegod 
recode worshipsamegodD 1/2=1 3/4=0

*biblical authority
gen biblelegend = (bibleword==2)
gen biblehaserrors = (bibleword==3)
gen bibletruebut = (bibleword==4)
gen bibleliterallytrue = (bibleword==5)

*nature of belief
gen nobelief = (belief==2)
gen dontknow = (belief==3)
gen cosmic = (belief==4)
gen believesometimes = (belief==5)
gen believewdoubt = (belief==6)
gen believeingod = (belief==7)

*biblical concepts
gen devilD = devil 
recode devilD 1/2=0 3/4=1
gen heavenD = heaven 
recode heavenD 1/2=0 3/4=1
gen hellD = hell 
recode hellD 1/2=0 3/4=1
gen purgatoryD = purgatory 
recode purgatoryD 1/2=0 3/4=1
gen armageddonD = armageddon 
recode armageddonD 1/2=0 3/4=1
gen angelsD = angels 
recode angelsD 1/2=0 3/4=1
gen demonsD = demons
recode demonsD 1/2=0 3/4=1 

********************************************************************************
*in order to run the LCA plug in, vars need to be coded 1,2
********************************************************************************

gen allreligtrueD_lca 		=	allreligtrueD		+1
gen worshipsamegodD_lca 	=	worshipsamegodD		+1
gen biblelegend_lca 		= 	biblelegend			+1
gen biblehaserrors_lca 		=	biblehaserrors		+1
gen bibletruebut_lca 		= 	bibletruebut		+1
gen bibleliterallytrue_lca 	=	bibleliterallytrue	+1
gen nobelief_lca 			= 	nobelief			+1
gen dontknow_lca			=	dontknow			+1
gen cosmic_lca				=	cosmic				+1
gen believesometimes_lca 	=	believesometimes	+1
gen believewdoubt_lca		=	believewdoubt		+1
gen believeingod_lca		=	believeingod		+1
gen devilD_lca			 	=	devilD				+1
gen heavenD_lca			 	=	heavenD				+1
gen hellD_lca			 	=	hellD				+1
gen purgatoryD_lca			=	purgatoryD			+1
gen armageddonD_lca			=	armageddonD			+1
gen angelsD_lca			 	=	angelsD				+1
gen demonsD_lca			 	=	demonsD				+1

*literalism religious beliefs = more or less "biblical literalism" or an index
*  of core "fundamentalist" beliefs
factor bibleword devil-demons
rotate, oblimin
predict literalism
*recoding into deciles for a little better analytic control:
xtile literalism10 = literalism, n(10)
*rescaling:
gen literalism01 = (literalism10-1)/9


********************************************************************************
*demographics
********************************************************************************
*age 
gen age = Q55Y
replace age = . if age ==2010
replace age = (age-1902)
replace age = age/96
*education
gen educ = I_EDUC
replace educ = (educ-1)/5
*gender
gen male = (Q54==1)
*income
gen income = Q70
replace income = (income-1)/6
*perceived control
egen control = rmean( Q74E Q74H )
gen control01 = (control-1)/3
*trust
factor Q48A-Q48D, pcf
rotate, oblimin
predict trustscale
sum trustscale
gen trustscale01 = (trustscale-r(min))/(r(max)-r(min))

********************************************************************************
*for factor analysis - input items
********************************************************************************
gen Absolute = absoluteD_lca 
gen Critical = criticalD_lca 
gen Fatherly = fatherlyD_lca 
gen Punishing = punishingD_lca 
gen Just  = justD_lca
gen Wrathful = wrathfulD_lca
gen Forgiving = forgivingD_lca
gen Severe = severeD_lca
gen Involved = involvedinworldD_lca
gen Angered_by_sin = angeredbyhumansinD_lca
gen Never_fails = godneverfailsD_lca

factor Absolute-Never_fails, pf
rotate, oblimin blanks(.5)
predict pos neg
loadingplot // charting factor loadings in space

sum pos
gen pos01 = (pos-r(min))/(r(max)-r(min))
sum neg
gen neg01 = (neg-r(min))/(r(max)-r(min))

twoway(scatter LCA pos01, mcolor(white) mlcolor(black) ylabel(1 "Class 1: Indefinite and univolved" 2 "Class 2: Loving father, involved" 3 "Class 3: God as Nullity" 4 "Class 4: Loving father, uninvolved" 5 "Class 5: Wrathful, loving, involved")) || scatter latent_divine neg01, mcolor(black%50) mlcolor(black)


********************************************************************************
*identifying obs used in sample
********************************************************************************
mlogit latent_divine evangel blackprot none jewish catholic protestant charismatic performance01 literalism01 universalism01 trustscale01 control01  age white black educ male income
predict p1
gen modelobs = 1 if p1!=.
drop p1
label var modelobs "obs used in MNL model" 

********************************************************************************
*for the latent class and factor comparison: 

gen LCA  = latent_divine +cond(pos, 0.1, -0.1)
